<template>
   <el-card>
        <el-form :model="queryParams" ref="queryParams" :inline="true" label-width="120px">
            <el-form-item label="网关分组：" prop="ip">
               <el-input v-model="queryParams.ip" placeholder="来源IP" size="small"></el-input>
            </el-form-item>
            <el-form-item label="回调方式：" prop="service">
                <el-select v-model="queryParams.service" placeholder="请选择" size="small">
                    <el-option v-for="item in FrontendList" :label="item" :key="item" :value="item"></el-option>
                  </el-select>
            </el-form-item>
             <el-form-item label="前端服务名：" prop="path">
                <el-input v-model="queryParams.path" placeholder="前端API路径" size="small"></el-input>
            </el-form-item>
             <el-form-item label="前端路径：" prop="path">
                <el-input v-model="queryParams.path" placeholder="前端API路径" size="small"></el-input>
            </el-form-item>
             <el-form-item label="请求方法：" prop="service">
                <el-select v-model="queryParams.service" placeholder="请选择" size="small">
                    <el-option v-for="item in FrontendList" :label="item" :key="item" :value="item"></el-option>
                  </el-select>
            </el-form-item>
             <el-form-item label="插件" prop="service">
                <el-select v-model="queryParams.service" placeholder="请选择" size="small">
                    <el-option v-for="item in FrontendList" :label="item" :key="item" :value="item"></el-option>
                  </el-select>
            </el-form-item>
             <el-form-item label="访问" prop="service">
                <el-select v-model="queryParams.service" placeholder="请选择" size="small">
                    <el-option v-for="item in FrontendList" :label="item" :key="item" :value="item"></el-option>
                  </el-select>
            </el-form-item>
            <el-form-item >
                <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-delete" size="small" @click="resetQuery('queryParams')">清空</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="tableData" border style="width: 100%" size="small">
            <el-table-column type="index" label="#" width="50"></el-table-column>
            <el-table-column label="回放ID" prop="ip"></el-table-column>
            <el-table-column label="回放时间" prop="service"></el-table-column>
            <el-table-column label="操作人" prop="path"></el-table-column>
            <el-table-column label="请求ID" prop="qps"></el-table-column>
            <el-table-column label="请求源IP" prop="concurrent"></el-table-column>
            <el-table-column label="请求时间" prop="concurrent"></el-table-column>
            <el-table-column label="请求方法" prop="concurrent"></el-table-column>
            <el-table-column label="前端服务名" prop="concurrent"></el-table-column>
            <el-table-column label="前端路径" prop="concurrent"></el-table-column>
            <el-table-column label="查询字符串" prop="concurrent"></el-table-column>
            <el-table-column label="回放方式" prop="concurrent"></el-table-column>
            <el-table-column label="回放结果" prop="concurrent"></el-table-column>
            <el-table-column label="操作" width="200" align="center">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
                    <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                v-show="total>0"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                background
                :current-page="1"
                :page-sizes="[10, 20, 30, 40,50,100]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                class="pagination-container"
                :total="total">
            </el-pagination>
    </el-card>
</template>

<script>
import {getCallbackList} from '@/api/callback/config.api.js'
    export default {
        data() {
            return {
                queryParams: {},
                tableData: [],
                
            }
        },
        mounted() {
            this.getList();
        },
        methods: {
            handleAdd() {
                this.$router.push({path: '/callback/detail/add'})
            },
            getList() {
                getCallbackList(this.queryParams).then(res=>{
                    if(res.code === 200) {
                        this.tableData = res.data.records;
                        this.total = res.data.total;
                    }
                })
            },
               // 搜索
            handleQuery() {
                this.queryParams.current = 1;
                this.getList();
            },
            // 清空
            resetQuery(formName) {
                this.$refs[formName].resetFields();
                this.getList();
            },
            handleSizeChange(val) {
                this.queryParams.size = val;
                this.getList();
           },
            handleCurrentChange(val) {
                this.queryParams.current = val;
                this.getList();
            },
        }
    }
</script>
<style lang="scss" scoped>
.pagination-container {
    padding: 10px;
    text-align: right;
}
</style>